#encoding:utf-8 
import os, logging

def template_VER_LUA(cls, templatepath, tarfile):
    src_verrfile = os.path.join(templatepath, "VER.lua")
    vrlua = open(src_verrfile, "r+")
    readv = vrlua.read().encode("utf8")
    vrlua.close()
    vwlua = open(tarfile, "w")
    retval = readv.replace("@VER_INT@", cls._resver)
    vwlua.write(retval)
    logging.info("Out put VER.lua ---->>>\n %s", retval)
    vwlua.close()

def template_RELEASE_LUA(cls, templatepath, tarfile):
    src_releasefile = os.path.join(templatepath, "RELEASE.lua")
    vrlua = open(src_releasefile, "r+")
    readv = vrlua.read()
    vrlua.close()
    vwlua = open(tarfile, "w")
    retval = readv.replace("@PLAT_ID@", str(cls._platid)) \
                    .replace("@PLAT_NAME@", str(cls._platform)) \
                    .replace("@LANGUAGE_NAME@", str(cls._lang)) 
    vwlua.write(retval)

    logging.info("Out put RELEASE.lua--->>\n %s", retval)
    vwlua.close()   
